<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>图书管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function btnInsert(id) {
			// 正常打开
			if(!id){
				id = "";
			}
			top.$.jBox.open("iframe:${ctx}/book/books/toInsert?id="+id, "新增从编", 400, 160, {
				buttons: {}, loaded: function () {
					$(".jbox-content", top.document).css("overflow-y", "hidden");
				}, closed: function () {
					$("#booksName").val(window.parent.editbooks);
				}
			});
		}

		function deleteBooksInfo(bkId) {
			if(confirm("确定要删除编目信息？")){
				deleteBooksAjax(bkId);
			}
		}
		function deleteBooksAjax(bkId) {
			$.ajax({
				type: "POST",
				url: "${ctx}/book/books/delete",
				data: {id: bkId},
				dataType: "json",
				success: function (data) {
					if (data.code == "0001") {
						top.$.jBox.info(data.msg, '提示', {
							closed: function () {
								window.location.href = "${ctx}/book/books/list";
							}
						});
						top.$('.jbox-body .jbox-icon').css('top', '55px');

					} else {
						alertx("删除丛编信息失败");
					}
				}
			});
		}

		function btnClear() {
			$("#searchForm").find("input[type='text']").each(function () {
				$(this).val("");
			});
		}
	</script>
</head>
<body>
	<form:form id="searchForm" modelAttribute="bkBooks" action="${ctx}/book/books/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>题名：</label><form:input id="booksName" path="booksName" htmlEscape="false" maxlength="30" class="input-medium"/>&nbsp;
		<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>&nbsp;&nbsp;
		<a href="javascript:void(0)" onclick="btnClear()" class="btn">清空条件</a>
		<a href="javascript:void(0)" onclick="btnInsert()" class="btn">新增</a>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
		<tr>
			<th>序号</th>
			<th>套装书名</th>
			<%--<th>套装本数</th>--%>
			<th>操作</th>
		</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="info" varStatus="status">
			<tr>
				<td>${status.count}</td>
				<td>${info.booksName}</td>
				<%--<td>${info.booksNumber}</td>--%>
				<td>
					<a href="javascript:void(0)" onclick="btnInsert('${info.id}')">修改</a>
					<shiro:hasPermission name="book:books:delete">
						<a href="javascript:void(0);" onclick="deleteBooksInfo('${info.id}')">删除</a>
					</shiro:hasPermission>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>